namespace Runoi.DataBase;

/// <summary>
///  数据库过滤器
/// </summary>
public static class SqlSugarFilter
{
    /// <summary>
    /// 缓存全局查询过滤器（内存缓存）
    /// </summary>
    private static readonly ICache _cache = Cache.Default;

    /// <summary>
    /// 删除自定义过滤器缓存
    /// </summary>
    /// <param name="userId"></param>
    /// <param name="dbConfigId"></param>
    public static void DeleteCustomCache(long userId, string dbConfigId)
    {
        // 删除自定义缓存——过滤器
        _cache.Remove($"db:{dbConfigId}:custom:{userId}");
    }

    /// <summary>
    /// 自定义实体过滤器接口
    /// </summary>
    public interface IEntityFilter
    {
        /// <summary>
        /// 实体过滤器
        /// </summary>
        /// <returns></returns>
        IEnumerable<TableFilterItem<object>> AddEntityFilter();
    }
}